package Client;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.rmi.RemoteException;

import RMI.RmiService;
import Watcher.watchService;
import XML.ConfigHelper;

/**
 * this is the main class, that start all the needed things
 * @author liel && guy
 *
 */
public class SocketClient 
{
	/**
	 * run the client side
	 */
	public void run() 
	{
		System.out.println("in socket client");
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

		ClientDetails clientDetails = null;
		try 
		{
			clientDetails=ConfigHelper.readXmlClient();
		} 
		catch (Exception e) 
		{
			e.printStackTrace();
		}
		//		ClientDetails clientDetails = new ClientDetails(userName, password , DropBoxpath, email);
		watchService wsService=watchService.getWsInstance();
		wsService.setClientDetails(clientDetails);

		Manager manager = Manager.getInstance();
		manager.setClientDetails(clientDetails);
		ServerToClient serverToClient = ServerToClient.getInstance();
		serverToClient.setClientDetails(clientDetails);
		
		//create thread of watcher, manager, and server to client
		Thread t1= new Thread(wsService);
		Thread t2 = new Thread (manager);
		Thread t3 = new Thread(serverToClient);

		//run all  threads
		t1.start();
		t2.start();
		t3.start();

		try {
			RmiService rs=new RmiService();
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
